<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<head>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<link rel="stylesheet" href="<%=basePath %>css/bootstrap.css"/>
<link rel="stylesheet" href="<%=basePath %>css/buttons.css" />
<script type="text/javascript" src="<%=basePath %>js/jquery-1.9.1.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<script type="text/javascript">
$(document).ready(function(){
	$("#exit").click(function(){
		location.href = "<%=basePath %>index.jsp";
	});
	$("#sel").click(function(){
		location.href = "<%=basePath%>ticketinfo/selAll";
	});
}); 

function del(trainnumber){
	if(confirm("是否确定退掉车次【" + trainnumber + "】的票？")){
		location.href = "<%=basePath %>ticketinfo/del?trainnumber=" + trainnumber;
  	}else{
	  	return false;
  	}
}
function update(trainnumber){
	if(confirm("是否确定支付车次【" + trainnumber + "】的票款？")){
		location.href = "<%=basePath %>ticketinfo/update?trainnumber=" + trainnumber;
  	}else{
	  	return false;
  	}
}

</script>
<body onload="">
	<center>
		<br /> <input id="sel" type="button" value="查询" class="button button-pill button-primary"
					style="width: 140px; height: 40px;" />&nbsp;&nbsp; 
			   <input id="exit" type="button" value="返回" class="button button-pill button-primary"
					style="width: 140px; height: 40px;" />
		<table class="table table-hover" style="width: 500px;" align="center" border="0">
			<tr>
				<td>车次</td>
				<td>座位</td>
				<c:if test="${sessionScope.user.fusername == 'admin'}">
					<td>姓名</td>
					<td>证件号</td>
					<td>是否支付</td>
					<td>购票时IP</td>
				</c:if>
				
				<td></td>
			</tr>
			<c:forEach items="${ticketList }" var="ticketList">
				<tr>
					<td>${ticketList.ftrainnumber }</td>
					<td>${ticketList.ftype }</td>
					<c:if test="${sessionScope.user.fusername == 'admin'}">
						<td>${ticketList.fusername }</td>
						<td>${ticketList.fcertificateno }</td>
						<td>${ticketList.fpay }</td>
						<td>${ticketList.fip }</td>
					</c:if>
					
					<td>
						<c:if test="${ticketList.fpay == 0 }">
							<input type="button" value="支付" id="pay" class="button button-pill button-primary"
										style="width: 70px; height: 30px; font-size: 10px;" onclick="update('${ticketList.ftrainnumber}')"/>
						</c:if>
						<c:if test="${ticketList.fpay == 1 }">
							<input type="button" value="已付" id="pay" class="button button-pill button-primary"
										style="width: 70px; height: 30px; font-size: 10px;" disabled="true"/>
						</c:if>&nbsp;&nbsp;
						<input type="button" value="退票" id="del" class="button button-pill button-primary"
										style="width: 70px; height: 30px; font-size: 10px;" onclick="del('${ticketList.ftrainnumber}')"/>
					</td>
				</tr>
			</c:forEach>
		</table>
	</center>
</body>
</html>